package com.wetao.lib_common.greendao.dao;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.wetao.lib_common.greendao.model.PagePicture;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "PAGE_PICTURE".
*/
public class PagePictureDao extends AbstractDao<PagePicture, Long> {

    public static final String TABLENAME = "PAGE_PICTURE";

    /**
     * Properties of entity PagePicture.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property PictureUrl = new Property(1, String.class, "pictureUrl", false, "PICTURE_URL");
        public final static Property BigPicWidth = new Property(2, Integer.class, "bigPicWidth", false, "BIG_PIC_WIDTH");
        public final static Property BigPicHeight = new Property(3, Integer.class, "bigPicHeight", false, "BIG_PIC_HEIGHT");
        public final static Property PictureId = new Property(4, Integer.class, "pictureId", false, "PICTURE_ID");
        public final static Property BookId = new Property(5, Integer.class, "bookId", false, "BOOK_ID");
        public final static Property PageNumber = new Property(6, Integer.class, "pageNumber", false, "PAGE_NUMBER");
        public final static Property SectionNo = new Property(7, Integer.class, "sectionNo", false, "SECTION_NO");
        public final static Property OwnerNo = new Property(8, Integer.class, "ownerNo", false, "OWNER_NO");
        public final static Property Pageserial = new Property(9, String.class, "pageserial", false, "PAGESERIAL");
        public final static Property IsMore = new Property(10, boolean.class, "isMore", false, "IS_MORE");
        public final static Property IsHttp = new Property(11, boolean.class, "isHttp", false, "IS_HTTP");
        public final static Property StartX_L = new Property(12, Float.class, "startX_L", false, "START_X__L");
        public final static Property StartY_L = new Property(13, Float.class, "startY_L", false, "START_Y__L");
        public final static Property EndX_L = new Property(14, Float.class, "endX_L", false, "END_X__L");
        public final static Property EndY_L = new Property(15, Float.class, "endY_L", false, "END_Y__L");
        public final static Property StartX_R = new Property(16, Float.class, "startX_R", false, "START_X__R");
        public final static Property StartY_R = new Property(17, Float.class, "startY_R", false, "START_Y__R");
        public final static Property EndX_R = new Property(18, Float.class, "endX_R", false, "END_X__R");
        public final static Property EndY_R = new Property(19, Float.class, "endY_R", false, "END_Y__R");
        public final static Property OssUrl = new Property(20, String.class, "ossUrl", false, "OSS_URL");
        public final static Property Scale = new Property(21, Integer.class, "scale", false, "SCALE");
        public final static Property AssistantExamId = new Property(22, Long.class, "assistantExamId", false, "ASSISTANT_EXAM_ID");
    }

    private DaoSession daoSession;

    private Query<PagePicture> assistantExam_PictureListQuery;

    public PagePictureDao(DaoConfig config) {
        super(config);
    }
    
    public PagePictureDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
        this.daoSession = daoSession;
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"PAGE_PICTURE\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"PICTURE_URL\" TEXT," + // 1: pictureUrl
                "\"BIG_PIC_WIDTH\" INTEGER," + // 2: bigPicWidth
                "\"BIG_PIC_HEIGHT\" INTEGER," + // 3: bigPicHeight
                "\"PICTURE_ID\" INTEGER NOT NULL UNIQUE ," + // 4: pictureId
                "\"BOOK_ID\" INTEGER," + // 5: bookId
                "\"PAGE_NUMBER\" INTEGER," + // 6: pageNumber
                "\"SECTION_NO\" INTEGER," + // 7: sectionNo
                "\"OWNER_NO\" INTEGER," + // 8: ownerNo
                "\"PAGESERIAL\" TEXT," + // 9: pageserial
                "\"IS_MORE\" INTEGER NOT NULL ," + // 10: isMore
                "\"IS_HTTP\" INTEGER NOT NULL ," + // 11: isHttp
                "\"START_X__L\" REAL," + // 12: startX_L
                "\"START_Y__L\" REAL," + // 13: startY_L
                "\"END_X__L\" REAL," + // 14: endX_L
                "\"END_Y__L\" REAL," + // 15: endY_L
                "\"START_X__R\" REAL," + // 16: startX_R
                "\"START_Y__R\" REAL," + // 17: startY_R
                "\"END_X__R\" REAL," + // 18: endX_R
                "\"END_Y__R\" REAL," + // 19: endY_R
                "\"OSS_URL\" TEXT," + // 20: ossUrl
                "\"SCALE\" INTEGER," + // 21: scale
                "\"ASSISTANT_EXAM_ID\" INTEGER NOT NULL );"); // 22: assistantExamId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PAGE_PICTURE\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, PagePicture entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String pictureUrl = entity.getPictureUrl();
        if (pictureUrl != null) {
            stmt.bindString(2, pictureUrl);
        }
 
        Integer bigPicWidth = entity.getBigPicWidth();
        if (bigPicWidth != null) {
            stmt.bindLong(3, bigPicWidth);
        }
 
        Integer bigPicHeight = entity.getBigPicHeight();
        if (bigPicHeight != null) {
            stmt.bindLong(4, bigPicHeight);
        }
        stmt.bindLong(5, entity.getPictureId());
 
        Integer bookId = entity.getBookId();
        if (bookId != null) {
            stmt.bindLong(6, bookId);
        }
 
        Integer pageNumber = entity.getPageNumber();
        if (pageNumber != null) {
            stmt.bindLong(7, pageNumber);
        }
 
        Integer sectionNo = entity.getSectionNo();
        if (sectionNo != null) {
            stmt.bindLong(8, sectionNo);
        }
 
        Integer ownerNo = entity.getOwnerNo();
        if (ownerNo != null) {
            stmt.bindLong(9, ownerNo);
        }
 
        String pageserial = entity.getPageserial();
        if (pageserial != null) {
            stmt.bindString(10, pageserial);
        }
        stmt.bindLong(11, entity.getIsMore() ? 1L: 0L);
        stmt.bindLong(12, entity.getIsHttp() ? 1L: 0L);
 
        Float startX_L = entity.getStartX_L();
        if (startX_L != null) {
            stmt.bindDouble(13, startX_L);
        }
 
        Float startY_L = entity.getStartY_L();
        if (startY_L != null) {
            stmt.bindDouble(14, startY_L);
        }
 
        Float endX_L = entity.getEndX_L();
        if (endX_L != null) {
            stmt.bindDouble(15, endX_L);
        }
 
        Float endY_L = entity.getEndY_L();
        if (endY_L != null) {
            stmt.bindDouble(16, endY_L);
        }
 
        Float startX_R = entity.getStartX_R();
        if (startX_R != null) {
            stmt.bindDouble(17, startX_R);
        }
 
        Float startY_R = entity.getStartY_R();
        if (startY_R != null) {
            stmt.bindDouble(18, startY_R);
        }
 
        Float endX_R = entity.getEndX_R();
        if (endX_R != null) {
            stmt.bindDouble(19, endX_R);
        }
 
        Float endY_R = entity.getEndY_R();
        if (endY_R != null) {
            stmt.bindDouble(20, endY_R);
        }
 
        String ossUrl = entity.getOssUrl();
        if (ossUrl != null) {
            stmt.bindString(21, ossUrl);
        }
 
        Integer scale = entity.getScale();
        if (scale != null) {
            stmt.bindLong(22, scale);
        }
        stmt.bindLong(23, entity.getAssistantExamId());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PagePicture entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String pictureUrl = entity.getPictureUrl();
        if (pictureUrl != null) {
            stmt.bindString(2, pictureUrl);
        }
 
        Integer bigPicWidth = entity.getBigPicWidth();
        if (bigPicWidth != null) {
            stmt.bindLong(3, bigPicWidth);
        }
 
        Integer bigPicHeight = entity.getBigPicHeight();
        if (bigPicHeight != null) {
            stmt.bindLong(4, bigPicHeight);
        }
        stmt.bindLong(5, entity.getPictureId());
 
        Integer bookId = entity.getBookId();
        if (bookId != null) {
            stmt.bindLong(6, bookId);
        }
 
        Integer pageNumber = entity.getPageNumber();
        if (pageNumber != null) {
            stmt.bindLong(7, pageNumber);
        }
 
        Integer sectionNo = entity.getSectionNo();
        if (sectionNo != null) {
            stmt.bindLong(8, sectionNo);
        }
 
        Integer ownerNo = entity.getOwnerNo();
        if (ownerNo != null) {
            stmt.bindLong(9, ownerNo);
        }
 
        String pageserial = entity.getPageserial();
        if (pageserial != null) {
            stmt.bindString(10, pageserial);
        }
        stmt.bindLong(11, entity.getIsMore() ? 1L: 0L);
        stmt.bindLong(12, entity.getIsHttp() ? 1L: 0L);
 
        Float startX_L = entity.getStartX_L();
        if (startX_L != null) {
            stmt.bindDouble(13, startX_L);
        }
 
        Float startY_L = entity.getStartY_L();
        if (startY_L != null) {
            stmt.bindDouble(14, startY_L);
        }
 
        Float endX_L = entity.getEndX_L();
        if (endX_L != null) {
            stmt.bindDouble(15, endX_L);
        }
 
        Float endY_L = entity.getEndY_L();
        if (endY_L != null) {
            stmt.bindDouble(16, endY_L);
        }
 
        Float startX_R = entity.getStartX_R();
        if (startX_R != null) {
            stmt.bindDouble(17, startX_R);
        }
 
        Float startY_R = entity.getStartY_R();
        if (startY_R != null) {
            stmt.bindDouble(18, startY_R);
        }
 
        Float endX_R = entity.getEndX_R();
        if (endX_R != null) {
            stmt.bindDouble(19, endX_R);
        }
 
        Float endY_R = entity.getEndY_R();
        if (endY_R != null) {
            stmt.bindDouble(20, endY_R);
        }
 
        String ossUrl = entity.getOssUrl();
        if (ossUrl != null) {
            stmt.bindString(21, ossUrl);
        }
 
        Integer scale = entity.getScale();
        if (scale != null) {
            stmt.bindLong(22, scale);
        }
        stmt.bindLong(23, entity.getAssistantExamId());
    }

    @Override
    protected final void attachEntity(PagePicture entity) {
        super.attachEntity(entity);
        entity.__setDaoSession(daoSession);
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public PagePicture readEntity(Cursor cursor, int offset) {
        PagePicture entity = new PagePicture( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // pictureUrl
            cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2), // bigPicWidth
            cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // bigPicHeight
            cursor.getInt(offset + 4), // pictureId
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // bookId
            cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // pageNumber
            cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7), // sectionNo
            cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8), // ownerNo
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // pageserial
            cursor.getShort(offset + 10) != 0, // isMore
            cursor.getShort(offset + 11) != 0, // isHttp
            cursor.isNull(offset + 12) ? null : cursor.getFloat(offset + 12), // startX_L
            cursor.isNull(offset + 13) ? null : cursor.getFloat(offset + 13), // startY_L
            cursor.isNull(offset + 14) ? null : cursor.getFloat(offset + 14), // endX_L
            cursor.isNull(offset + 15) ? null : cursor.getFloat(offset + 15), // endY_L
            cursor.isNull(offset + 16) ? null : cursor.getFloat(offset + 16), // startX_R
            cursor.isNull(offset + 17) ? null : cursor.getFloat(offset + 17), // startY_R
            cursor.isNull(offset + 18) ? null : cursor.getFloat(offset + 18), // endX_R
            cursor.isNull(offset + 19) ? null : cursor.getFloat(offset + 19), // endY_R
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // ossUrl
            cursor.isNull(offset + 21) ? null : cursor.getInt(offset + 21), // scale
            cursor.getLong(offset + 22) // assistantExamId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PagePicture entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setPictureUrl(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setBigPicWidth(cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2));
        entity.setBigPicHeight(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
        entity.setPictureId(cursor.getInt(offset + 4));
        entity.setBookId(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
        entity.setPageNumber(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6));
        entity.setSectionNo(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7));
        entity.setOwnerNo(cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8));
        entity.setPageserial(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setIsMore(cursor.getShort(offset + 10) != 0);
        entity.setIsHttp(cursor.getShort(offset + 11) != 0);
        entity.setStartX_L(cursor.isNull(offset + 12) ? null : cursor.getFloat(offset + 12));
        entity.setStartY_L(cursor.isNull(offset + 13) ? null : cursor.getFloat(offset + 13));
        entity.setEndX_L(cursor.isNull(offset + 14) ? null : cursor.getFloat(offset + 14));
        entity.setEndY_L(cursor.isNull(offset + 15) ? null : cursor.getFloat(offset + 15));
        entity.setStartX_R(cursor.isNull(offset + 16) ? null : cursor.getFloat(offset + 16));
        entity.setStartY_R(cursor.isNull(offset + 17) ? null : cursor.getFloat(offset + 17));
        entity.setEndX_R(cursor.isNull(offset + 18) ? null : cursor.getFloat(offset + 18));
        entity.setEndY_R(cursor.isNull(offset + 19) ? null : cursor.getFloat(offset + 19));
        entity.setOssUrl(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
        entity.setScale(cursor.isNull(offset + 21) ? null : cursor.getInt(offset + 21));
        entity.setAssistantExamId(cursor.getLong(offset + 22));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(PagePicture entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(PagePicture entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(PagePicture entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "pictureList" to-many relationship of AssistantExam. */
    public List<PagePicture> _queryAssistantExam_PictureList(Long assistantExamId) {
        synchronized (this) {
            if (assistantExam_PictureListQuery == null) {
                QueryBuilder<PagePicture> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.AssistantExamId.eq(null));
                assistantExam_PictureListQuery = queryBuilder.build();
            }
        }
        Query<PagePicture> query = assistantExam_PictureListQuery.forCurrentThread();
        query.setParameter(0, assistantExamId);
        return query.list();
    }

}
